package com.ssl.security.util;

import com.ssl.security.constants.KeyFactoryAlgEnum;

import java.security.KeyFactory;

/**
 * 描述：keyFactory 工具类
 *
 * @author ssl
 * @create 2021/3/19 0019.
 */
public class KeyFactoryUtils {
    /**
     * 获取指定算法的keyFactory
     *
     * @param algorithm
     * @return
     */
    public static KeyFactory getKeyFactory(String algorithm) throws Exception {
        KeyFactory keyFactory = KeyFactory.getInstance(algorithm);
        return keyFactory;
    }

    /**
     * 获取RSA算法的keyFactory
     *
     * @return
     */
    public static KeyFactory getRSAKeyFactory() throws Exception {
        return getKeyFactory(KeyFactoryAlgEnum.RSA.getValue());
    }

}
